package wdevent

import (
	"time"
)

var entity = NewEventEntity()

func GetEventEntity() *Entity {
	return entity
}

func init() {
	entity.RegisterGlobal(Recover)
}

func SetMaxCycle(max int) {
	entity.maxCycle = max
}
func SetTimeout(to time.Duration) {
	entity.timeout = to
}
func RegisterEvent(s string, handle EventHandle) {
	entity.RegisterEvent(s, handle)
}
func RegisterMiddle(s string, handle EventHandle) {
	entity.RegisterMiddle(s, handle)
}
func RegisterGlobal(handle EventHandle) {
	entity.RegisterGlobal(handle)
}
func Dispatch(key string, ctx *Context) error {
	return entity.Dispatch(key, ctx)
}
